package com.sikaryofficial.backend.domain.dto.resp;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.sikaryofficial.backend.annotation.LikesDataFormat;
import com.sikaryofficial.backend.constant.ContentStatusEnum;
import com.sikaryofficial.backend.domain.vo.EvaluateContentObj;
import com.sikaryofficial.common.core.annotation.LocalDateTimeFormat;
import com.sikaryofficial.system.api.model.att.AttachmentResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 品牌口味评价对象
 *
 * @author qinjinyuan
 * @date 2023-10-30
 */
@Getter
@Setter
@ToString
@ApiModel(value = "口味评价出参", description = "口味评价出参")
public class BrandTasteEvaluateDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "序号")
    private Integer seqNo;

    /**
     * 评价内容
     */
    @ApiModelProperty(value = "评价内容")
    private String remark;

    /**
     * 创建人名称
     */
    @ApiModelProperty(value = "创建人名称")
    private String createdName;

    @ApiModelProperty(value = "昵称")
    private String nickName;
    /**
     * 创建人ID
     */
    @ApiModelProperty(value = "创建人ID")
    private Long createdBy;
    /**
     * 创建时间, 伦敦所在的时区为GMT+1，也被称为西一区
     */
    @LocalDateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间", example = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;

    /**
     * 评价ID
     */
    @ApiModelProperty(value = "评价ID", example = "1212435")
    private Long evaluateId;

    /**
     * 品牌口味ID
     */
    @ApiModelProperty(value = "品牌口味ID", example = "12.2435")
    private Long brandTasteId;

    /**
     * 跟评列表
     */
    @ApiModelProperty(value = "跟评列表", example = "12.2435")
    private List<EvaluateReplyDTO> replyList;

    /**
     * 产品名称
     */
    @ApiModelProperty(value = "产品名称")
    private String productName;

    /**
     * 品牌编码
     */
    @ApiModelProperty(value = "品牌编码", example = "12.2435")
    private String brandNo;

    /**
     * 型号
     */
    @ApiModelProperty(value = "型号", example = "12.2435")
    private String model;

    /**
     * 口味名称
     */
    @ApiModelProperty(value = "口味名称", example = "12.2435")
    private String tasteName;

    /**
     * 款式: style:disposable 一次性,cartridge 弹药筒,opentype 开放式
     */
    @ApiModelProperty(value = "款式: style:disposable 一次性,cartridge 弹药筒,opentype 开放式", example = "disposable")
    private String style;

    /**
     * 品牌封面图片
     */
    @ApiModelProperty(value = "品牌封面图片", example = "12.2435")
    private String coverUrl;

    @ApiModelProperty(value = "个人图像-统一默认头像")
    private String avatar;


    /**
     * 是否屏蔽：0-否，1-是，默认未屏蔽
     */
    private Integer hasBlocked;

    /**
     * 评价图片
     */
    @ApiModelProperty(value = "评价图片", example = "12.2435")
    private List<AttachmentResp> attachmentList;

    /**
     * 评价指标
     */
    @ApiModelProperty(value = "评价指标", example = "12.2435")
    private List<EvaluateContentObj> evaluateContent;

    public List<EvaluateContentObj> getEvaluateContent() {
        if (CollUtil.isNotEmpty(evaluateContent)) {
            return evaluateContent;
        }
        List<EvaluateContentObj> evaluateContents = Lists.newArrayList();
        if (CharSequenceUtil.isNotBlank(evaluateContentObj)) {
            evaluateContents = JSONObject.parseObject(evaluateContentObj,new TypeReference<List<EvaluateContentObj>>(){});
        }
        return evaluateContents;
    }

    @JsonIgnore
    private String evaluateContentObj;

    /**
     * 综合评分(小数)
     */
    @ApiModelProperty(value = "综合评分(小数)", example = "12.2435")
    private BigDecimal compositeScore;

    /**
     * 状态
     */
    @ApiModelProperty(value = "状态 0-正常 1-屏蔽 2-举报")
    private int status;

    public String getStatusDesc() {
        ContentStatusEnum statusEnum = ContentStatusEnum.getNameByCode(status);
        if (Objects.nonNull(statusEnum)) {
            return statusEnum.getName();
        }
        return "";
    }

    /**
     * 点赞统计
     */
    @ApiModelProperty(value = "点赞统计", example = "123")
    @LikesDataFormat
    private Integer likesCount;
    /**
     * 点赞统计
     */
    @ApiModelProperty(value = "回复统计", example = "123")
    @LikesDataFormat
    private Integer replyCount;

    /**
     * 是否有我的点赞
     */
    @ApiModelProperty(value = "是否有我的点赞")
    private boolean hasOwnerLikes;

    /** 用户邮箱 */
    @ApiModelProperty(value = "用户邮箱")
    private String email;

    /** 国家 */
    @ApiModelProperty(value = "国家")
    private String country;
}
